<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<main>
    <h1>1</h1>
    <p>2</p>
    <h1>3</h1>
</main>
</body>
<script>
//取别名?<con>
let main  = document.querySelector("body main");
let reg = /<(h[1-6])>(?<con>.*?)<\/\1>/gi
main.innerHTML = main.innerHTML.replace(reg, "<h4>$<con></h4>");

//exec 可以判断某个字符出现几次
let str = "大家好啊大家好，家和万事兴，无家可归"
let regs = /家/g;
let count = 0
while(res = regs.exec(str)){
    console.log(res);
    count++
}
console.log(count);

//=? 后面是谁    比如/大家=?(好啊)/  就只匹配第一个大家
// ?<= 前面是谁
// ?! 后面不是
</script>
</html>